package com.ubs.ejb;

import java.util.List;

import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.annotation.ejb.LocalBinding;

import com.ubs.dom.Service;
import com.ubs.persistence.PersistenceUtils;

/**
 * Session Bean implementation class ServiceController
 */
@Stateful
@LocalBinding(jndiBinding="ubs/ServiceController")
public class ServiceController implements ServiceControllerLocal {

	@PersistenceContext(name="ubs-jpa")
	private transient EntityManager em;
	
	private boolean diagnosticMode;
	
    /**
     * Default constructor. 
     */
    public ServiceController() {
    }

	@SuppressWarnings("unchecked")
	@Override
	public List<Service> getPrimaryServices(Boolean visible) {
		
		List resultList = em.createNamedQuery("ServiceEntity.selectPrimaryServices")
		  		.setParameter("visible", PersistenceUtils.boolToString(visible))
		  		.getResultList();
		
		return resultList;
	}

	@Override
	public void setDiagnosticMode(boolean enabled) {
		this.diagnosticMode = enabled;
	}

}
